1 //+------------------------------------------------------------------+
\r
2 //| AXDX Advanced.mq4 |
\r
3 //| Copyright © 2011, Zarko Asenov |
\r
5 //+------------------------------------------------------------------+
\r
6 #property copyright "Copyright © 2011, Zarko Asenov"
\r
9 #property indicator_separate_window
\r
10 #property indicator_buffers 4
\r
11 #property indicator_color1 Salmon
\r
12 #property indicator_color2 Aqua
\r
13 #property indicator_color3 Silver
\r
14 #property indicator_color4 Gold
\r
15 #property indicator_level1 50.0
\r
16 #property indicator_level2 -50.0
\r
17 #property indicator_maximum 100.0
\r
18 #property indicator_minimum -100.0
\r
20 //--- input parameters
\r
21 extern int ADX_Period = 13;
\r
22 extern int Time_Frame = 240;
\r
24 double ExtMapBuffer0[];
\r
25 double ExtMapBuffer1[];
\r
26 double ExtMapBuffer2[];
\r
27 double ExtMapBuffer3[];
\r
29 double tf_factor = 0.0;
\r
31 //+------------------------------------------------------------------+
\r
32 //| Custom indicator initialization function |
\r
33 //+------------------------------------------------------------------+
\r
37 SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_DOT);
\r
38 SetIndexBuffer(0,ExtMapBuffer1);
\r
39 SetIndexStyle(1,DRAW_LINE, STYLE_DOT);
\r
40 SetIndexBuffer(1,ExtMapBuffer2);
\r
41 SetIndexStyle(2,DRAW_LINE, STYLE_DOT);
\r
42 SetIndexBuffer(2,ExtMapBuffer0);
\r
43 SetIndexStyle(3,DRAW_HISTOGRAM, STYLE_SOLID);
\r
44 SetIndexBuffer(3,ExtMapBuffer3);
\r
46 tf_factor = Period();
\r
47 tf_factor = tf_factor / Time_Frame;
\r
52 //+------------------------------------------------------------------+
\r
53 //| Custom indicator deinitialization function |
\r
54 //+------------------------------------------------------------------+
\r
62 //+------------------------------------------------------------------+
\r
63 //| Custom indicator iteration function |
\r
64 //+------------------------------------------------------------------+
\r
67 int counted_bars = IndicatorCounted();
\r
70 for (ix = Bars - counted_bars;ix >= 0; ix--) {
\r
75 int timeframe_ix = MathFloor(tf_factor * ix);
\r
76 adx_plus = iADX(Symbol(), Time_Frame, ADX_Period, PRICE_TYPICAL, 1, timeframe_ix);
\r
77 adx_minus = iADX(Symbol(), Time_Frame, ADX_Period, PRICE_TYPICAL, 2, timeframe_ix);
\r
79 double adx_diff = adx_plus - adx_minus;
\r
80 double adx_weigh = 0.0;
\r
82 if (adx_diff < 0.0 && adx_minus != 0.0) {
\r
83 adx_weigh = adx_diff / adx_minus;
\r
84 } else if (adx_diff > 0.0 && adx_plus != 0.0) {
\r
85 adx_weigh = adx_diff / adx_plus;
\r
90 int num_bars_period = MathRound(1.0 / tf_factor);
\r
94 ExtMapBuffer0[ix] = adx_weigh;
\r
95 ExtMapBuffer1[ix] = adx_weigh;
\r
96 ExtMapBuffer2[ix] = ExtMapBuffer1[ix] - ExtMapBuffer1[ix + num_bars_period];
\r
98 if (adx_weigh >= 0.0)
\r
99 ExtMapBuffer3[ix] = MathMax(0.0, MathMin(ExtMapBuffer2[ix], ExtMapBuffer0[ix]));
\r
100 else if (adx_weigh < 0.0)
\r
101 ExtMapBuffer3[ix] = MathMin(0.0, MathMax(ExtMapBuffer2[ix], ExtMapBuffer0[ix]));
\r
106 //+------------------------------------------------------------------+